<?xml version="1.0" encoding= "UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/common.xhtml">
	<ui:define name="content">
		<h:form>
			<p:commandLink id="newM" action="#{messageBean.newMessage}"  style="margin-left:20px">
				<h:outputText value="Write message" />
			</p:commandLink>
			<pre></pre>
			<p:tabView rendered="#{not empty userBean.self}">
				<p:tab title="All messages">
					<h:panelGrid columns="2" cellpadding="10">
						<p:dataTable var="message" value="#{messageBean.messageList}">
							<p:column headerText="Time">
								<h:outputText value="#{message.messageTime}" />
							</p:column>
							<p:column headerText="Text">
								<h:outputText value="#{message.messageText}" />
							</p:column>
							<p:column headerText="Sender">
								<h:outputText
									value="#{message.sender.firstName} #{message.sender.lastName}" />
							</p:column>
							<p:column headerText="Receiver">
								<h:outputText
									value="#{message.receiver.firstName} #{message.receiver.lastName}" />
							</p:column>


						</p:dataTable>
					</h:panelGrid>
				</p:tab>
				<p:tab title="Sended messages">
					<h:panelGrid columns="2" cellpadding="10">
						<p:dataTable var="message" value="#{messageBean.sendedMessages}">
							<p:column headerText="Time">
								<h:outputText value="#{message.messageTime}" />
							</p:column>
							<p:column headerText="Text">
								<h:outputText value="#{message.messageText}" />
							</p:column>
							
							<p:column headerText="Receiver">
								<h:outputText
									value="#{message.receiver.firstName} #{message.receiver.lastName}" />
							</p:column>


						</p:dataTable>
					</h:panelGrid>
				</p:tab>
				<p:tab title="Received messages">
					<h:panelGrid columns="2" cellpadding="10">
						<p:dataTable var="message" value="#{messageBean.receivedMessages}">
							<p:column headerText="Time">
								<h:outputText value="#{message.messageTime}" />
							</p:column>
							<p:column headerText="Text">
								<h:outputText value="#{message.messageText}" />
							</p:column>
							<p:column headerText="Sender">
								<h:outputText
									value="#{message.sender.firstName} #{message.sender.lastName}" />
							</p:column>



						</p:dataTable>
					</h:panelGrid>
				</p:tab>
			</p:tabView>
			<pre></pre>
			<p:commandButton value="Back" action="/home" style="margin-left:20px" />
		</h:form>
	</ui:define>

</ui:composition>


</html>
